// @ts-nocheck
import React from 'react';
import { connect } from '../dva'
// import { connect } from 'dva'
function Counter(props) {
    const { number, onDecrease, onIncrease, onAdd, onAsyncAdd, loading } = props
    return <div>
        <h1>{number}</h1>
        <div>
            <button onClick={onIncrease}> + </button>
            <button onClick={onDecrease}> - </button>
            <button onClick={() => onAdd(10)}> +10 </button>
            <button onClick={() => onAsyncAdd(15)}>延迟2s +15</button>
        </div>
        <div>loading:{loading + ''}</div>
    </div>;
}

export default connect(state => ({
    number: state.counter,
    loading: state.loading.models.counter,
}), dispatch => ({
    onDecrease: () => dispatch({ type: 'counter/decrease' }),
    onIncrease: () => dispatch({ type: 'counter/increase' }),
    onAdd: (payload) => dispatch({ type: 'counter/add', payload }),
    onAsyncAdd: (payload) => dispatch({ type: 'counter/asyncAdd', payload }),
}))(Counter)